package xjtu.se.articlecommunity.admin.busermanage.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xjtu.se.articlecommunity.admin.busermanage.ManageService;
import xjtu.se.articlecommunity.admin.busermanage.dao.ManageDao;
import xjtu.se.articlecommunity.admin.busermanage.dto.User;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class ManageServiceImpl implements ManageService {

    @Resource
    private ManageDao manageDao;

    @Override
    public List<User> getBUserList() {
        List<User> userList = manageDao.getBUserList();
        for (int i = 0; i < userList.size(); i++) {
            userList.get(i).setKey(i+1);
        }
        return userList;
    }

    @Override
    public List<User> getBUserApplyList() {
        List<User> userList = manageDao.getBUserApplyList();
        for (int i = 0; i < userList.size(); i++) {
            userList.get(i).setKey(i+1);
        }
        return userList;
    }

    @Override
    public void delete(User user) {
        manageDao.delete(user);
    }

    @Override
    public void newBUser(User user) {
        manageDao.newBUser(user);
    }
}
